{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<!--<style type="text/css">-->
<!--    .layui-layer-page .layui-layer-content {-->
<!--        overflow: inherit;-->
<!--    }-->
<!--</style>-->
<div class="layui-card">
    <div class="layui-card-header">缺货登记</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
    </div>
</div>
<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.name}}">

</script>
<script type="text/html" id="barTool">

<!--<a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("goodsDiscountEdit")}?id={{ d.id }}' data-title="会员优惠">会员优惠</a>-->
<a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("detail")}?id={{ d.id }}' data-title="查看详情">查看详情</a>
<!--<a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("edithd")}?id={{ d.id }}' data-title="活动设置">活动设置</a>-->
<!--    {if $userInfo['roleid']==1}-->
<!--    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"-->
<!--       data-full="true">编辑</a>-->
<!--    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'-->
<!--       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>-->
<!--    {/if}-->
</script>

<!--selectList: {0: '未补货', 1: '已补货'}-->

<script type="text/html" id="recommendTpl">
    <input type="checkbox" name="recommend" data-href='{:url("recommend")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="推荐|不推荐" lay-filter="switchStatus" {{ d.recommend==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="已补货|未补货" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTplc">
    <input type="checkbox" name="is_show_c" data-href='{:url("setstatec")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="显示|关闭" lay-filter="switchStatus" {{ d.is_show_c==1 ? 'checked' : '' }}>
</script>



{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function () {
        // var table = layui.table,
        //     $ = layui.$,
        //     form = layui.form,
        //     table = layui.table,
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add',['catid'=>$catid])}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };
        var goods_cate = {:json_encode($goodsCategoty)};
        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            url: '{:url("index")}',
            // searchFormTpl:,
            toolbar: ['refresh',
                // [{
                //     text: '添加',
                //     url: init.add_url,
                //     method: 'open',
                //     icon: 'iconfont icon-add',
                //     class: 'layui-btn layui-btn-normal layui-btn-sm',
                //     extend: 'data-full="true"',
                // }],
            ],
              cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id',fixed: 'left',align: "center",  width: '4%', title: 'ID'},
                    {field: 'nickname', width: '10%', align: "center",title: '昵称',searchOp: 'like'},
                    {field: 'avatarUrl', width: '8%', align: "center",title: '图片', search: false, templet: '#picTpl' },
                    {field: 'name',align: "center",  width: '15%', title: '零件名称'},
                    {field: 'model',align: "center",  width: '8%', title: '型号'},
                    {field: 'num',align: "center",  width: '8%', title: '数量'},
                    {field: 'phone',align: "center",  width: '10%', title: '电话'},
                    {
                        field: 'status',
                        width: '10%',
                        align: "center",
                        title: '状态',
                        templet: '#statusTpl',
                        unresize: true,
                        selectList: {0: '未补货', 1: '已补货'}
                    },
                    {field: 'create_time',  width: '15%', align: "center", title: '创建时间', search: 'range'},
                    // {field: 'remark',align: "center",  width: '15%', title: '备注'},


                      {fixed: 'right',  width: '10%',align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
        yznTable.bindevent();
    });
</script>
{/block}